package com.wyg.blog.service.serviceimpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wyg.blog.mapper.TagMapper;
import com.wyg.blog.model.blog.Tag;
import com.wyg.blog.service.blog.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: WYG
 * @time: 2020/6/30 20:25
 */
@Service
public class TagServiceImpl implements TagService {
    @Autowired
    TagMapper tagMapper;

    @Override
    public List<Tag> selectAllTags() {
        return tagMapper.getAllTags();
    }

    @Override
    public List<Tag> selectLatestTags() {
        return tagMapper.getLatestTags();
    }

    @Override
    public Integer selectTagCount() {
        return tagMapper.getTagCount();
    }

    @Override
    public IPage<Tag> selectSomeTags(Page<?> page) {
        return tagMapper.getSomeTags(page);
    }

    @Override
    public Tag selectTagByName(String name) {
        return tagMapper.getTagByName(name);
    }

    @Override
    public Tag selectTagById(Integer id) {
        return tagMapper.getTagById(id);
    }

    @Override
    public String selectTagNameById(Integer id) {
        return tagMapper.getTagNameById(id);
    }

    @Override
    public List<String> selectTagNameByBid(Integer bid) {
        return tagMapper.getTagNmeByBid(bid);
    }

    @Override
    public boolean insertTag(Tag tag) {
        return tagMapper.addTag(tag);
    }

    @Override
    public boolean renewTagState(Integer id, boolean state) {
        return tagMapper.updateTagState(id, state);
    }

    @Override
    public boolean renewTag(Integer id, String tag) {
        return tagMapper.updateTag(id, tag);
    }

    @Override
    public boolean removeTag(Integer id) {
        return tagMapper.deleteTag(id);
    }

    @Override
    public List<Tag> fuzzySearch(String tag) {
        return tagMapper.getTagByLike(tag);
    }
}
